package com.shuzixiangcun.controller.front;

import com.shuzixiangcun.entity.Xiangcunimg;

import com.shuzixiangcun.service.front.XiangcunimgFServiceImpl;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 乡村相册表(Xiangcunimg)表控制层
 *
 * @author makejava
 * @since 2024-06-24 08:26:19
 */
@RestController
@RequestMapping("/xiangcunimg")
public class XiangcunimgFController {
    /**
     * 服务对象
     */
    @Resource
    private XiangcunimgFServiceImpl xiangcunimgService;



    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<Xiangcunimg> queryById(@PathVariable("id") Object id) {
        return ResponseEntity.ok(this.xiangcunimgService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param xiangcunimg 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<Xiangcunimg> add(Xiangcunimg xiangcunimg) {
        return ResponseEntity.ok(this.xiangcunimgService.insert(xiangcunimg));
    }

    /**
     * 编辑数据
     *
     * @param xiangcunimg 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<Xiangcunimg> edit(Xiangcunimg xiangcunimg) {
        return ResponseEntity.ok(this.xiangcunimgService.update(xiangcunimg));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Object id) {
        return ResponseEntity.ok(this.xiangcunimgService.deleteById(id));
    }

}

